//Entrepreneur v. Inventor Risk Paper
//PNAS ANALYSIS CODE

// Create "input" and "output" subfolders
// Place three data files into "input" subfolder
// if needed for ado file, ssc install eclplot

cap n log close
log using PNAS_Final.log, replace
clear all
set more off

****************************
** Descriptive Statistics
****************************

**Table T2
use "input\CIC Survey.dta", clear
	*All
tabstat entrepreneur ceo_nonentrepreneur employee_inventor employee_noninventor age_d1 age_d2 age_d3 age_d4 age_d5  female doctorate if core == 1, statistics (mean sd count)
	**for MA locations -- Space == 1, 2, 3
bysort space: tabstat entrepreneur ceo_nonentrepreneur employee_inventor employee_noninventor age_d1 age_d2 age_d3 age_d4 age_d5  female doctorate if core == 1, statistics (mean sd count)
	**For St. Louis -- location == 2
bysort location: tabstat entrepreneur ceo_nonentrepreneur employee_inventor employee_noninventor age_d1 age_d2 age_d3 age_d4 age_d5  female doctorate if core == 1, statistics (mean sd count)

**Table T3a-d
use "input\CIC Survey.dta", clear
tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d , statistics (mean sd count)
tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if core == 1, statistics (mean sd count)

drop if core != 1
tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if entrepreneur == 1, statistics (mean sd count)
tab firmsfounded_groups if entrepreneur==1
tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if ceo_nonentrepreneur == 1, statistics (mean sd count)
tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if employee_inventor == 1, statistics (mean sd count)
tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if employee_noninventor == 1, statistics (mean sd count)

bysort inventor: tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d inventor if entrepreneur==1, statistics (mean sd count)
tab firmsfounded_groups if entrepreneur==1 & inventor == 0
tab firmsfounded_groups if entrepreneur==1 & inventor == 1
bysort stem: tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d inventor if entrepreneur==1, statistics (mean sd count)
tab firmsfounded_groups if entrepreneur==1 & stem == 0
tab firmsfounded_groups if entrepreneur==1 & stem == 1

bysort inventor: tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if ceo_nonentrepreneur == 1, statistics (mean sd count)
bysort stem: tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d inventor if ceo_nonentrepreneur == 1, statistics (mean sd count)

bysort inventor: tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d if employee == 1, statistics (mean sd count)
bysort stem: tabstat female immigrant age_d* asian black hisp white othrace bama doctorate educ_other stem businessecon field_other industry_experience_d startup_experience_workedin_d startup_experience_founded_d inventor if employee == 1, statistics (mean sd count)

**Table 5a-b
use "input\CIC Survey.dta", clear
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness , statistics(mean sd count)
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if entrepreneur == 1, statistics(mean sd count)
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if ceo_nonentrepreneur == 1, statistics(mean sd count)
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if employee_inventor == 1, statistics(mean sd count)
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if employee_noninventor == 1, statistics(mean sd count)

bysort female: tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if entrepreneur == 1, statistics(mean sd count)
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if entrepreneur_12 == 1, statistics(mean sd count)
tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if entrepreneur_3 == 1, statistics(mean sd count)
bysort inventor: tabstat personality_enjoyrisks personality_financialrisks giftcard_01 trait_openness trait_conscientiousness trait_extraversion trait_agreeableness trait_neuroticism trait_selfefficacy trait_internallocusofcontrol trait_needforachievement trait_innovativeness if entrepreneur == 1, statistics(mean sd count)

****************************
** Regressions
****************************
use "input\CIC Survey.dta", clear

//Dep var

loc dv1 "enj_risk"
loc dv2 "enj_finrisk"
loc dv3 "giftcard_01"
loc dv_risk `dv1' `dv2' `dv3'

loc dv4 "trait_openness"
loc dv5 "trait_conscientiousness"
loc dv6 "trait_extraversion"
loc dv7 "trait_agreeableness"
loc dv8 "trait_neuroticism"
loc dv_big5 `dv4' `dv5' `dv6' `dv7' `dv8'

loc dv9 "trait_selfefficacy"
loc dv10 "trait_internallocusofcontrol"
loc dv11 "trait_needforachievement" 
loc dv12 "trait_innovativeness"
loc dv_othertraits `dv9' `dv10' `dv11' `dv12'

loc dv_all `dv_risk' `dv_big5' `dv_othertraits'

//Indep var

loc ivar1 "female" 
loc ivar2 "fulltime"
loc ivar3 "young"
loc ivar4 "immigrant"
loc ivar5 "doctorate bama"
loc ivar6 "white"  
loc ivar7 "stem businessecon"
loc ivar8 "industry_experience_d" 

loc ivar_types1 "entrepreneur ceo_nonentrepreneur employee_inventor"
loc ivar_types2 "entrepreneur_inventor entrepreneur_noninventor ceo_inventor ceo_noninventor  employee_inventor"

loc ivar_table6 `ivar_types1' `ivar1' `ivar2' `ivar3' `ivar4' `ivar5' `ivar6' `ivar7' `ivar8'
loc ivar_table8 `ivar_types2' `ivar1' `ivar2' `ivar3' `ivar4' `ivar5' `ivar6' `ivar7' `ivar8'

**Table 6 
eststo clear

foreach dv in `dv_risk' {
eststo: reg `dv' `ivar_table6', cluster(clientnumber)
}

esttab using "output\Table6a.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps
eststo clear

foreach dv in `dv_big5' {
eststo: reg `dv' `ivar_table6', cluster(clientnumber)
}

esttab using "output\Table6b.csv", csv replace se stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps 
eststo clear

foreach dv in `dv_othertraits' {
eststo: reg `dv' `ivar_table6', cluster(clientnumber)
}

esttab using "output\Table6c.csv", csv replace se stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps 
eststo clear

**Table 7
	*A: copy coefficients from Table 6
	*B: sample excluding firms > 25
	*C: Sample excluding non-founding owners

foreach dv in `dv_risk' {
eststo: reg `dv' `ivar_table6' if ctpeople <= 25, cluster(clientnumber)
}

esttab using "output\Table7a_B.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps

eststo clear

foreach dv in `dv_big5' {
eststo: reg `dv' `ivar_table6' if ctpeople <= 25, cluster(clientnumber)
}

esttab using "output\Table7b_B.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps

eststo clear

foreach dv in `dv_othertraits' {
eststo: reg `dv' `ivar_table6' if ctpeople <= 25, cluster(clientnumber)
}

esttab using "output\Table7c_B.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps

eststo clear

preserve
keep if core == 1 & position != 3 

foreach dv in `dv_risk' {
eststo: reg `dv' `ivar_table6', cluster(clientnumber)
}

esttab using "output\Table7a_C.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps

eststo clear

foreach dv in `dv_big5' {
eststo: reg `dv' `ivar_table6', cluster(clientnumber)
}

esttab using "output\Table7b_C.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps

eststo clear

foreach dv in `dv_othertraits' {
eststo: reg `dv' `ivar_table6', cluster(clientnumber)
}

esttab using "output\Table7c_C.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps

eststo clear

restore

**Table 8
eststo clear

foreach dv in `dv_risk' {
eststo: reg `dv' `ivar_table8', cluster(clientnumber)
}

esttab using "output\Table8a.csv", csv replace se r2 stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps
eststo clear

foreach dv in `dv_big5' {
eststo: reg `dv' `ivar_table8', cluster(clientnumber)
}

esttab using "output\Table8b.csv", csv replace se stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps 
eststo clear

foreach dv in `dv_othertraits' {
eststo: reg `dv' `ivar_table8', cluster(clientnumber)
}

esttab using "output\Table8c.csv", csv replace se stats(N) star(* 0.10 ** 0.05 *** 0.01) label nogaps 
eststo clear

******************
** Figures
*****************

use "input\Figure 1.dta", clear
eclplot est low high depvar, horizontal supby(group, spaceby(0.15)) estopts(msize(large)) ciopts(msize(large)) ytitle("") xtitle("Coefficient of the group indicator variable" "shown with 95% confidence interval") ylabel(1(1)11 1"Enjoy General Risk" 2"Enjoy Financial Risk" 3"Openness" 4"Conscientiousness" 5"Extraversion" 6"Agreeableness" 7"Neuroticism" 8"Self-Efficacy" 9"Internal LOC" 10"Need for Achievement" 11"Innovativeness") xline(0, lcolor(black) lwidth(0.25)) legend(label(1 "Entrepreneur") label(2 "CEO: Non-Entrepreneurs") label(3 "Employee: Inventor") ring(0) position(4) bmargin(small) size(small) cols(1)) title("Personality traits by venture role" "compared to non-inventor employees", color(black) span) graphregion(color(white)) plotregion(margin(l+0 r+1))
graph export "output\Figure 1.png", as(png) replace

use "input\Figure 2.dta", clear
twoway connected GeneralRisk role, title("Risk tolerance by venture role" "compared to non-inventor employees", color(black) span) xlabel(1 "Employee: Non-Inventor" 2 "Employee: Inventor" 3 "CEO/Leader" 4 "Entrepreneur") xtitle("")legend(rows(1) stack ring(0) position(10) bmargin(small) size(small)) ytitle("Relative Risk Premium") ylabel(0(.1).45, angle(0)) ymtick(#10) msize(small) msymbol(O) || connected FinancialRisk role, msize(small) msymbol(S) graphregion(color(white)) plotregion(margin(l+7 r+7 b=0))|| connected LotteryPercentYes role, msize(small) msymbol(T)
graph export "output\Figure 2.png", replace

clear
log close


